package protocol;

import com.google.common.collect.Sets;

import java.util.Set;

public interface ProtocolConstant {
    String SIMPLE_STRING_PREFIX = "+";
    String MULTI_STRING_PREFIX = "$";
    String INTEGER_NUMBER_PREFIX = ":";
    String ERROR_PREFIX = "-ERR ";
    String LIST_PREFIX = "*";
    String PONG = "PONG";

    String KEY_DEL = "DEL";
    String KEY_EXISTS = "EXISTS";
    String KEY_EXPIRE = "EXPIRE";
    String KEY_EXPIRE_AT = "EXPIREAT";
    String KEY_KEYS = "KEYS";
    String KEY_TTL = "TTL";
    String KEY_RANDOM_KEY = "RANDOMKEY";
    String KEY_RENAME = "RENAME";
    String KEY_RENAMENX = "RENAMENX";
    String KEY_TYPE = "TYPE";

    Set<String> KEY_CMDS = Sets.newHashSet(KEY_DEL, KEY_EXISTS, KEY_EXPIRE, KEY_EXPIRE_AT, KEY_KEYS,
            KEY_TTL, KEY_RANDOM_KEY, KEY_RENAME, KEY_RENAMENX, KEY_TYPE);

    String STRING_SET = "SET";
    String STRING_GET = "GET";
    String STRING_GETRANGE = "GETRANGE";
    String STRING_GETSET = "GETSET";
    String STRING_MGET = "MGET";
    String STRING_SETEX = "SETEX";
    String STRING_SETNX = "SETNX";
    String STRING_STRLEN = "STRLEN";
    String STRING_MSET = "MSET";
    String STRING_INCR = "INCR";
    String STRING_INCRBY = "INCRBY";
    String STRING_INCRBYFLOAT = "INCRBYFLOAT";
    String STRING_DECR = "DECR";
    String STRING_DECRBY = "DECRBY";
    String STRING_APPEND = "APPEND";

    Set<String> STRING_CMDS = Sets.newHashSet(STRING_SET, STRING_GET, STRING_GETRANGE,
            STRING_GETSET, STRING_MGET, STRING_SETEX, STRING_SETNX,
            STRING_STRLEN, STRING_MSET, STRING_INCR, STRING_INCRBY,
            STRING_INCRBYFLOAT, STRING_DECR, STRING_DECRBY, STRING_APPEND);

    String HASH_HDEL = "HDEL";
    String HASH_HEXISTS = "HEXISTS";
    String HASH_HGET = "HGET";
    String HASH_HGETALL = "HGETALL";
    String HASH_HINCRBY = "HINCRBY";
    String HASH_HINCRBYFLOAT = "HINCRBYFLOAT";
    String HASH_HKEYS = "HKEYS";
    String HASH_HLEN = "HLEN";
    String HASH_HMGET = "HMGET";
    String HASH_HMSET = "HMSET";
    String HASH_HSET = "HSET";
    String HASH_HSETNX = "HSETNX";
    String HASH_HVALS = "HVALS";

    Set<String> HASH_CMDS = Sets.newHashSet(HASH_HDEL, HASH_HEXISTS, HASH_HGET, HASH_HGETALL,
            HASH_HINCRBY, HASH_HINCRBYFLOAT, HASH_HKEYS, HASH_HLEN, HASH_HMGET, HASH_HMSET,
            HASH_HSET, HASH_HSETNX, HASH_HVALS);

    String LIST_LINDEX = "LINDEX";
    String LIST_LINSERT = "LINSERT";
    String LIST_LPOP = "LPOP";
    String LIST_LPUSH = "LPUSH";
    String LIST_LRANGE = "LRANGE";
    String LIST_LREM = "LREM";
    String LIST_LSET = "LSET";
    String LIST_LTRIM = "LTRIM";
    String LIST_RPOP = "RPOP";
    String LIST_RPUSH = "RPUSH";

    String LIST_BEFORE = "BEFORE";
    String LIST_AFTER = "AFTER";

    Set<String> LIST_CMDS = Sets.newHashSet(LIST_LINDEX, LIST_LINSERT, LIST_LPOP, LIST_LPUSH,
            LIST_LRANGE, LIST_LREM, LIST_LSET, LIST_LTRIM, LIST_RPOP, LIST_RPUSH);

    String SET_SADD = "SADD";
    String SET_SCARD = "SCARD";
    String SET_SDIFF = "SDIFF";
    String SET_SINTER = "SINTER";
    String SET_SISMEMBER = "SISMEMBER";
    String SET_SMEMBERS = "SMEMBERS";
    String SET_SMOVE = "SMOVE";
    String SET_SPOP = "SPOP";
    String SET_SRANDMEMBER = "SRANDMEMBER";
    String SET_SREM = "SREM";
    String SET_SUNION = "SUNION";
    String SET_SSCAN = "SSCAN";

    Set<String> SET_CMDS = Sets.newHashSet(SET_SADD, SET_SCARD, SET_SDIFF, SET_SINTER, SET_SISMEMBER,
            SET_SMEMBERS, SET_SMOVE, SET_SPOP, SET_SRANDMEMBER, SET_SREM, SET_SUNION, SET_SSCAN);

    String ZSET_ZADD = "ZADD";
    String ZSET_ZCARD = "ZCARD";
    String ZSET_ZCOUNT = "ZCOUNT";
    String ZSET_ZINCRBY = "ZINCRBY";
    String ZSET_ZLEXCOUNT = "ZLEXCOUNT";
    String ZSET_ZRANGE = "ZRANGE";
    String ZSET_ZRANGEBYLEX = "ZRANGEBYLEX";
    String ZSET_ZRANGEBYSCORE = "ZRANGEBYSCORE";
    String ZSET_ZRANGK = "ZRANGK";
    String ZSET_ZREM = "ZREM";
    String ZSET_ZREMRANGEBYLEX = "ZREMRANGEBYLEX";
    String ZSET_ZREMRANGEBYRANK = "ZREMRANGEBYRANK";
    String ZSET_ZREMRANGEBYSCORE = "ZREMRANGEBYSCORE";
    String ZSET_ZREVRANGE = "ZREVRANGE";
    String ZSET_ZREVRANGEBYSCORE = "ZREVRANGEBYSCORE";
    String ZSET_ZREVRANK = "ZREVRANK";
    String ZSET_ZSCORE = "ZSCORE";
    String ZSET_ZSCAN = "ZSCAN";

    Set<String> ZSET_CMDS = Sets.newHashSet(ZSET_ZADD, ZSET_ZCARD, ZSET_ZCOUNT, ZSET_ZINCRBY,
            ZSET_ZLEXCOUNT, ZSET_ZRANGE, ZSET_ZRANGEBYLEX, ZSET_ZRANGEBYSCORE, ZSET_ZRANGK, ZSET_ZREM,
            ZSET_ZREMRANGEBYLEX, ZSET_ZREMRANGEBYRANK, ZSET_ZREMRANGEBYSCORE, ZSET_ZREVRANGE, ZSET_ZREVRANGEBYSCORE,
            ZSET_ZREVRANK, ZSET_ZSCORE, ZSET_ZSCAN);

    /**
     * complete all need log cmd
     */
    Set<String> NEED_LOGS = Sets.newHashSet(KEY_DEL, KEY_RENAME, KEY_RENAMENX,
            STRING_SET, STRING_GETSET, STRING_MSET, STRING_SETEX, STRING_SETNX,
            STRING_INCR, STRING_INCRBY, STRING_INCRBYFLOAT, STRING_DECR, STRING_DECRBY, STRING_APPEND,
            LIST_LPUSH, LIST_RPUSH, LIST_RPOP, LIST_LPOP, LIST_LINSERT, LIST_LTRIM, LIST_LREM,
            SET_SADD, SET_SREM, SET_SMOVE,
            HASH_HDEL, HASH_HINCRBY, HASH_HINCRBYFLOAT, HASH_HSET, HASH_HSETNX, HASH_HMSET,
            ZSET_ZADD, ZSET_ZREM);

    String SERVER_PING = "PING";
    String SERVER_FLUSHDB = "FLUSHDB";
    String SERVER_DBSIZE = "DBSIZE";

    Set<String> SERVER_CMDS = Sets.newHashSet(SERVER_PING, SERVER_FLUSHDB, SERVER_DBSIZE);
}